package com.chenglu.android.payment;

import android.content.Context;
import android.content.Intent;

import com.chenglu.android.common.net.Constant;
import com.chenglu.android.common.utils.LogUtils;
import com.chenglu.android.goodsinfo.GoodsInfoActivity;
import com.chenglu.android.payment.bean.PayParam;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023/10/17 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：
 */
public class PayUtils {

    public static  JSONObject setPayParam(String orderNo, String payType,String id) {

        PayParam.PayOrderNoDTOList payOrderParam  = new PayParam.PayOrderNoDTOList();
        payOrderParam.setOrderNo(orderNo);
        payOrderParam.setPayType(payType);
        List<PayParam.PayOrderNoDTOList> payParamList = new ArrayList<>();
        payParamList.add(payOrderParam);

        JSONObject jsonObject = new JSONObject();

        try {
            jsonObject.put("payClient", Constant.APPCLIENT);
            if (payParamList != null) {
                // 1个数组参数
                JSONArray jsonArray = new JSONArray();
                JSONObject object = new JSONObject();
                for (int i = 0; i < payParamList.size(); i++) {
                    object.put("orderNo", payParamList.get(i).getOrderNo());
                    object.put("payType", payParamList.get(i).getPayType());

                }
                jsonArray.put(object);
                jsonObject.put("payOrderNoDTOList", jsonArray);
            }
            jsonObject.put("payTypeId",id);


        } catch (JSONException e) {
            e.printStackTrace();
            LogUtils.d("优惠卷参数的异常" + e.getMessage());
        }
        return jsonObject;
    }



}
